<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>发布历史</title>
    <link rel="stylesheet" type="text/css" href="../style/api.css" />
    <link rel="stylesheet" type="text/css" href="../style/head.css" />
    <link rel="stylesheet" type="text/css" href="../style/mui.min.css" />
    <style>
        #closeIt {
            position: absolute;
            top: 35px;
            left: 1rem;
            width: 2rem;
            height: 2rem;
        }

        main {
            padding-top: 75px;
            border-top: 1px solid #ccc;
        }

        .findNothing {
            display: none;
            color: #999;
            font-size: 1rem;
            text-align: center;
            padding: 1rem;
        }

        .lectureBox .lectureItem {
            width: 95%;
            position: relative;
            padding: 0.5rem 1rem;
            margin: 0.5rem auto;
            border-radius: 0.5rem;
            background-color: #fff;
        }

        .lectureItem-title {
            text-align: center padding: 0.5rem;
            border-bottom: 1px dashed #ccc;
        }

        .lectureItem-title .wait {
            position: absolute;
            top: 0;
            right: 0;
            width: 3rem;
            height: 3rem;
        }

        .lectureItem-title span {
            font-weight: bold;
            font-size: 1.2rem;
        }

        .lectureItem-body {
            padding: 0.5rem;
            color: #999;
            border-bottom: 1px dashed #ccc;
        }

        .lectureItem-body p {
            width: 100%;
            line-height: 1.5;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 3;
            overflow: hidden;
            margin-bottom: 0;
        }

        .lectureItem-bottom {
            padding: 0.5rem;
            display: flex;
            justify-content: flex-start;
            align-items: center;
            border-bottom: 1px dashed #ccc;
        }

        .lectureItem-bottom span:nth-child(1) {
            color: #3949AB;
            margin-right: 0.5rem;
        }

        .lectureItem-bottom span:nth-child(2) img {
            width: 2rem;
            height: 2rem;
            vertical-align: middle;
            border-radius: 50%;
        }

        .lectureItem-operation {
            padding: 0.5rem;
            text-align: center;
        }

        .lectureItem-operation span {
            color: orange;
            padding: 0.5rem;
            border-radius: 0.4rem;
            background-color: #3949AB;
        }
    </style>
</head>

<body>
    <header>
        发布
        <img src="../img/icons/back.png" alt="" onclick="api.closeWin()" id="closeIt">
    </header>
    <main>
        <div class="findNothing">-- 没有数据 --</div>
        <div class="lectureBox">

        </div>
    </main>
</body>
<script type="text/template" id="lecture">
    {{~it.items:value:index}}
    <div class="lectureItem animated bounceInLeft" data-id="{{=value.id}}">
        <div class="lectureItem-title">
            <span>【讲座】{{=value.issue_name}}</span>
            <img src="../img/icons/wait.png" alt="" class="wait">
        </div>
        <div class="lectureItem-body">
            <p>{{=value.issue_theme}}</p>
        </div>
        <div class="lectureItem-bottom">
            <span>主讲人:</span>
            <span>
              <img src="../img/icons/teacher.png" alt="">
              {{=value.issue_teacher}}
          </span>
        </div>
        <div class="lectureItem-operation">
            <span id="delete" data-id="{{=value.id}}">删除</span>
        </div>
    </div>
    {{~}}
</script>
<script type="text/javascript" src="../js/api.js"></script>
<script type="text/javascript" src="../js/doT.min.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/rend.js"></script>
<script type="text/javascript" src="../js/mui.min.js"></script>
<script type="text/javascript">
    apiready = function() {
        getAdded();
    };

    function getAdded() {
        api.ajax({
            url: 'http://114.116.243.15/newbtb/appinfo/queryMyActivity.lecture',
            method: 'post',
            data: {
                body: {
                    "btb_data": {
                        'issue_uid': $api.getStorage('userid')
                    }
                }
            }
        }, function(ret, err) {
            if (ret) {
                if (ret.btb_data.total > 0) {
                    $('.lectureBox').append(btbRender('lecture', ret.btb_data.records));
                    $('#delete').click(function() {
                        const _this = this;
                        var btnArray = ['否', '是'];
                        mui.confirm('确认删除？', '删除讲座', btnArray, function(e) {
                            if (e.index == 1) {
                                api.ajax({
                                    url: 'http://114.116.243.15/newbtb/appinfo/delete.lecture',
                                    method: 'post',
                                    data: {
                                        body: {
                                            "tbname": "lecture_issue",
                                            "id": $(_this).attr('data-id')
                                        }
                                    }
                                },function(ret, err){
                                    if (ret) {
                                        if(ret.status == 1) {
                                            api.toast({
                                                msg: '已删除',
                                                duration: 2000,
                                                location: 'bottom'
                                            });
                                            window.location.reload();
                                        }
                                    }
                                });
                            } else {
                                api.toast({
                                    msg: '取消删除',
                                    duration: 2000,
                                    location: 'bottom'
                                });
                            }
                        })
                    })
                } else {
                    setTimeout(function() {
                        $('.findNothing').show();
                    }, 1000)
                }
            }
        });
    }
</script>

</html>
